package com.douqu.game.core.config;

import com.douqu.game.core.config.common.GoodsData;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.util.LoadUtils;
import com.douqu.game.core.util.LogUtils;

/**
 * 在线奖励config
 */
public class OnlineRewardConfig extends GameObject {
    /**
     * 总时间
     */
    public int totalTime;
    /**
     * 奖励
     */
    public GoodsData[] reward;

    @Override
    public boolean check()
    {
        if(totalTime<=0)
        {
            LogUtils.error("OnlineRewardConfig check time is error -> id:" + id + " name:" + name);
            return false;
        }
        if(reward == null){
            LogUtils.error("OnlineRewardConfig check reward is null -> id:" + id + " name:" + name);
            return false;
        }
        return true;
    }


    @Override
    public boolean setVariable(String key, String value) {
        if ("reward".equals(key)){
            reward = LoadUtils.loadGoodDataToArray(key, value);
            return true;
        }else{
            return super.setVariable(key, value);
        }
    }

    @Override
    public String toString() {
        return "OnlineReward{" +
                "ID=" + id +
                ", totalTime='" + totalTime +
                "reward"+reward+'\'' +
                "} " + super.toString();
    }

}
